<!DOCTYPE html>












  


<html class="theme-next gemini use-motion" lang="Chinese">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '6.4.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="GitHub中P4仓库的地址：https://github.com/p4lang/ P4语言编译/转换流程  每个仓库的功用和说明仓库名称 仓库介绍 具体说明 是否可用 Behavior-model (BMV2) Rewrite of the behavioral model as a C++ project without auto-generated code (except for the">
<meta name="keywords" content="p4,github">
<meta property="og:type" content="article">
<meta property="og:title" content="来聊聊P4的GitHub仓库吧">
<meta property="og:url" content="http://blog.zhengzi.me/2017/01/19/e6-9d-a5-e8-81-8a-e8-81-8ap4-e7-9a-84github-e4-bb-93-e5-ba-93/index.html">
<meta property="og:site_name" content="政子的博客">
<meta property="og:description" content="GitHub中P4仓库的地址：https://github.com/p4lang/ P4语言编译/转换流程  每个仓库的功用和说明仓库名称 仓库介绍 具体说明 是否可用 Behavior-model (BMV2) Rewrite of the behavioral model as a C++ project without auto-generated code (except for the">
<meta property="og:locale" content="Chinese">
<meta property="og:image" content="http://blog.zhengzi.me/wp-content/uploads/2017/01/p4流程.png">
<meta property="og:updated_time" content="2018-08-21T09:49:42.773Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="来聊聊P4的GitHub仓库吧">
<meta name="twitter:description" content="GitHub中P4仓库的地址：https://github.com/p4lang/ P4语言编译/转换流程  每个仓库的功用和说明仓库名称 仓库介绍 具体说明 是否可用 Behavior-model (BMV2) Rewrite of the behavioral model as a C++ project without auto-generated code (except for the">
<meta name="twitter:image" content="http://blog.zhengzi.me/wp-content/uploads/2017/01/p4流程.png">






  <link rel="canonical" href="http://blog.zhengzi.me/2017/01/19/e6-9d-a5-e8-81-8a-e8-81-8ap4-e7-9a-84github-e4-bb-93-e5-ba-93/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>来聊聊P4的GitHub仓库吧 | 政子的博客</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="Chinese">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">政子的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">强迫症|学习者|伪文青</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="Toggle navigation bar">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />Home</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />About</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />Tags</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />Archives</a>
  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://blog.zhengzi.me/2017/01/19/e6-9d-a5-e8-81-8a-e8-81-8ap4-e7-9a-84github-e4-bb-93-e5-ba-93/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Jason Bian">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="政子的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">来聊聊P4的GitHub仓库吧
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              

              
                
              

              <time title="Created: 2017-01-19 16:36:33" itemprop="dateCreated datePublished" datetime="2017-01-19T16:36:33+08:00">2017-01-19</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Edited on</span>
                
                <time title="Modified: 2018-08-21 17:49:42" itemprop="dateModified" datetime="2018-08-21T17:49:42+08:00">2018-08-21</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/P4/" itemprop="url" rel="index"><span itemprop="name">P4</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>GitHub中P4仓库的地址：<a href="https://github.com/p4lang/" target="_blank" rel="noopener">https://github.com/p4lang/</a></p>
<h2 id="P4语言编译-转换流程"><a href="#P4语言编译-转换流程" class="headerlink" title="P4语言编译/转换流程"></a>P4语言编译/转换流程</h2><p><a href="http://blog.zhengzi.me/wp-content/uploads/2017/01/p4流程.png"><img src="http://blog.zhengzi.me/wp-content/uploads/2017/01/p4流程.png" alt=""></a> </p>
<h2 id="每个仓库的功用和说明"><a href="#每个仓库的功用和说明" class="headerlink" title="每个仓库的功用和说明"></a>每个仓库的功用和说明</h2><p>仓库名称</p>
<p>仓库介绍</p>
<p>具体说明</p>
<p>是否可用</p>
<p>Behavior-model</p>
<p>(BMV2)</p>
<p>Rewrite of the behavioral model as a C++ project without auto-generated code (except for the PD interface)</p>
<p>新的Behavior-model，用于替换之前的p4c-behavioral，是一个新的P4运行时环境。</p>
<p>需要使用p4c-bm工具把P4代码转换成一个表示成软交换的json文件，</p>
<p>可以正常使用</p>
<p>p4c</p>
<p>P4_16 prototype compiler</p>
<p>解耦了前端编译和后端编译，均用统一的IR表示，前端针对P4_14和P4_16均可，后端可以编译为bmv2的json配置和ebpf的cpp代码</p>
<p>还在试验阶段，不过已经可用</p>
<p>p4factory</p>
<p>Compile P4 and run the P4 behavioral simulator</p>
<p>集合了P4的各种工具，可以直接让P4代码跑起来，在target文件夹中有许多p4-14的例子，并没有和P4-16工程同步更新</p>
<p>大体上可以跑起来，但是由于很久都没有更新，所以关于docker-image和INT应用的代码都已经broken，目前有修复的迹象（INT貌似已经修复）</p>
<p>p4c-bm</p>
<p>Generates the JSON configuration for the behavioral-model (bmv2), as well as the C/C++ PD code</p>
<p>为bmv2运行时环境生成json配置文件，（pd c++ code应该是protocol dependence cpp code）</p>
<p>可以正常使用</p>
<p>p4-hlir</p>
<p>（没有介绍）</p>
<p>P4的前端编译器，应该是针对于把P4代码转换成其他语言使用的（而且应该是针对于P4-14，因为P4-16已经将前端编译器放置于p4c的库中），使用bcc可以将P4解释为ebpf（和中间的c语言表示）</p>
<p>可以正常使用</p>
<p>ptf</p>
<p>Packet Test Framework</p>
<p>papers</p>
<p>Repository for papers related to P4</p>
<p>关于P4的一些文档和论文</p>
<p>switch</p>
<p>Consolidated switch repo (API, SAI and Nettlink)</p>
<p>包含了SAI和switchAPI的P4比较完整的switch示例（switch.p4），使用bmv2，支持INT，支持SAI</p>
<p>安装thrift的时候出现问题，没有运行成功，但理论上可以运行</p>
<p>ntf</p>
<p>Network Test Framework</p>
<p>基于mininet</p>
<p>还没有使用过</p>
<p>SAI</p>
<p>Switch Abstraction Interface</p>
<p>forked from opencomputeproject/SAI</p>
<p>p4-build</p>
<p>Infrastructure needed to generate, build and install the PD library for a given P4 program</p>
<p>为P4代码生成PD库（protocol dependence）</p>
<p>很久没更新了，但是目前可使用</p>
<p>p4ofagent</p>
<p>Openflow agent on a P4 dataplane</p>
<p>openflow控制器和P4运行时的中间翻译器</p>
<p>很久没更新了，还没使用过</p>
<p>tutorials</p>
<p>P4 language tutorials</p>
<p>一些会议或者活动的论文和示例，比如P4workshop和SIGCOMM</p>
<p>可用，应该去看看</p>
<p>p4c-behavioral</p>
<p>P4 compiler for the behavioral model</p>
<p>将P4代码编译成可以运行的代码，已经被bmv2代替</p>
<p>很久很久没更新了，更没有用过</p>
<p>scapy-vxlan</p>
<p>A scapy clone, with support for additional packet headers</p>
<p>使得scapy支持vxlan协议</p>
<p>可用</p>
<p>thrift</p>
<p>Mirror of Apache Thrift</p>
<p>thrift的镜像</p>
<p>可用</p>
<p>mininet</p>
<p>Emulator for rapid prototyping of Software Defined Networks <a href="http://mininet.org" target="_blank" rel="noopener">http://mininet.org</a></p>
<p>mininet的镜像</p>
<p>可用</p>
<p>PI</p>
<p>P4 PI headers and target-independent code</p>
<p>提供一个CLI下给bmv2提供流表得接口</p>
<p>可用</p>
<p>P4app</p>
<p>p4app is a tool that can build, run, debug, and test P4 programs. The philosophy behind p4app is “easy things should be easy” - p4app is designed to make small, simple P4 programs easy to write and easy to share with others.</p>
<p>一个可以编译、运行（14、16两种版本）、测试（ptf和mininet等）P4语言的库，它使用了一个封装好的docker镜像，并且把P4的运行变成了一个可以描述的工程</p>
<p>可用</p>
<p>Third-party</p>
<p>Third-party dependencies for p4lang software</p>
<p>P4仓库所依赖的一些第三方库</p>
<p>注：以上均根据最近尝试运行P4的GitHub代码时候的经验逐渐整理出，如有不对或者欠缺的地方希望得到大神们的指点。</p>

      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/p4/" rel="tag"># p4</a>
          
            <a href="/tags/github/" rel="tag"># github</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/01/01/2016-e7-9a-84-e6-9c-80-e5-90-8e-e4-b8-80-e5-a4-a9-ef-bc-8c-e8-bf-98-e6-98-af-e6-9d-a5-e8-af-b4-e7-82-b9-e4-bb-80-e4-b9-88/" rel="next" title="2016的最后一天，还是来说点什么">
                <i class="fa fa-chevron-left"></i> 2016的最后一天，还是来说点什么
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/01/20/e3-80-8amodern-php-e3-80-8b-e5-85-b3-e4-ba-8ephp-e7-9a-84-e6-9c-80-e4-bd-b3-e5-ae-9e-e8-b7-b5-e5-92-8c-e6-9c-80-e6-96-b0-e8-bf-9b-e5-b1-95/" rel="prev" title="《Modern PHP》——关于PHP的最佳实践和最新进展">
                《Modern PHP》——关于PHP的最佳实践和最新进展 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="Jason Bian" />
            
              <p class="site-author-name" itemprop="name">Jason Bian</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">86</span>
                    <span class="site-state-item-name">posts</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">41</span>
                    <span class="site-state-item-name">categories</span>
                  
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">109</span>
                    <span class="site-state-item-name">tags</span>
                  
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#P4语言编译-转换流程"><span class="nav-number">1.</span> <span class="nav-text">P4语言编译/转换流程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#每个仓库的功用和说明"><span class="nav-number">2.</span> <span class="nav-text">每个仓库的功用和说明</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jason Bian</span>

  

  
</div>




  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme – <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Gemini</a></div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.4.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.0"></script>



  



  










  





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
